#pragma once

#include "apdu.h"
#include "apdu_mgr_base.h"

class apdu_ecc_manager : public apdu_mgr_base
{
public:
	apdu_ecc_manager(void);
	~apdu_ecc_manager(void);

public:
	
	apdu * create_apdu_gen_ecc_keypair(int app_id, int container_id, int bits);
	
	apdu * create_apdu_import_ecc_keypair( int app_id, int container_id, 
								unsigned char * enveloped_key_blob, int key_blob_len);

	apdu * create_apdu_ecc_sign_data(int app_id, int container_id, int input_mode, 
								unsigned char * user_id, int id_len, 
								unsigned char * input_data, int data_len);

	apdu * create_apdu_ecc_sign_data_ex(int app_id, int container_id, int input_mode, int key_spec,
								unsigned char * user_id, int id_len, 
								unsigned char * input_data, int data_len);

	apdu * create_apdu_ecc_verify(unsigned char * ecc_pub_key_blob, int key_blob_len,
								unsigned char * input_data, unsigned long data_len, 
								unsigned char * ecc_signature_blob, int sig_blob_len );

	apdu * create_apdu_ecc_export_session_key( int app_id, int container_id, unsigned long alg_id,
										unsigned char * ecc_pub_key_blob, unsigned long key_blob_len );


	apdu * create_apdu_ecc_export_session_key_ex(int app_id, int container_id, int session_key_id,
										unsigned char * ecc_pub_key_blob, unsigned long key_blob_len );

	apdu * create_apdu_ecc_export_session_key2( int app_id, int container_id, int session_key_id, 
										unsigned char * ecc_pub_key_blob, unsigned long key_blob_len );

	apdu * create_apdu_ext_ecc_encrypt(unsigned char * ecc_pub_key_blob, unsigned long key_blob_len, 
								unsigned char * input_data, unsigned long data_len);

	apdu * create_apdu_gen_agreement_data_with_ecc( int app_id, int container_id, unsigned long alg_id,
								unsigned char * user_id, int id_len);

	apdu * create_apdu_gen_agreement_data_and_key_with_ecc(int app_id, int container_id, unsigned long alg_id,
								unsigned char * sponsor_pub_key_blob, unsigned long sponsor_key_blob_len, 
								unsigned char * tmp_pub_key_blob, unsigned long tmp_key_blob_len, 
								unsigned char * sponsor_id, int sponsor_id_len, 
								unsigned char * responser_id, int responser_id_len);


	apdu * create_apdu_gen_agreement_data_and_key_with_ecc_ex( int app_id, int container_id, int key_spec,
								unsigned long alg_id,
								unsigned char * sponsor_pub_key_blob,
								unsigned long sponsor_key_blob_len, 
								unsigned char * tmp_pub_key_blob, 
								unsigned long tmp_key_blob_len, 
								unsigned char * sponsor_id, 
								int sponsor_id_len, 
								unsigned char * responser_id, 
								int responser_id_len );

	apdu * create_apdu_gen_key_with_ecc(int app_id, int container_id, unsigned long agreement_handle, 
								unsigned char * pub_key_blob, unsigned long key_blob_len, 
								unsigned char * tmp_key_blob, unsigned long tmp_key_blob_len,
								unsigned char * responser_id, int responser_id_len);

	apdu * create_apdu_gen_key_with_ecc_ex( int app_id, int container_id, int key_spec, unsigned long agreement_handle,
								unsigned char * responser_pub_key_blob, unsigned long responser_key_blob_len,
								unsigned char * tmp_pub_key_blob, unsigned long tmp_key_blob_len,
								unsigned char * responser_id, int responser_id_len );

	apdu * create_apdu_ecc_private_decrypt(int app_id, int container_id, int key_spec, 
								unsigned char * input_data, unsigned long data_len);


	apdu * create_apdu_import_ext_ecc_keypair( int app_id, int container_id, int key_spec,
								unsigned char * ecc_key_blob, int key_blob_len);

	apdu * create_apdu_gen_ext_ecc_keypair();

	apdu * create_apdu_export_ext_ecc_pub_key();

	apdu * create_apdu_import_ext_ecc_keypair_to_ram(unsigned char * keypair_blob, int blob_len );

	apdu * create_apdu_ram_ecc_operation(int mode, unsigned char * data, int data_len);

	apdu * create_apdu_ecc_sign_data_interactive(int app_id, int container_id, int input_mode, 
						int key_spec,int timeout, unsigned char * user_id, int id_len,
						unsigned char * input_data, int data_len);

	apdu * create_apdu_ecc_sign_data_interactive_cancel(int app_id, int container_id, int input_mode, int key_spec);

};
